<?php

namespace app\api\controller;

use app\api\logic\HelpLogic;
use app\api\validate\HelpValidate;
use app\common\controller\Api;

class Help extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function list()
    {
        $param = [
            'page' => $this->request->get('page', 1),
            'limit' => $this->request->get('limit', 10),
            'keyword' => $this->request->get('keyword'),
        ];

        $validate = new HelpValidate();
        if (!$validate->scene('list')->check($param)) {
            return $this->error($validate->getError());
        }

        $logic = new HelpLogic();
        $data = $logic->getList($param);

        return $this->success('success', $data);
    }

    public function detail()
    {
        $param = [
            'id' => $this->request->get('id'),
        ];

        $validate = new HelpValidate();
        if (!$validate->scene('detail')->check($param)) {
            return $this->error($validate->getError());
        }

        $logic = new HelpLogic();
        $data = $logic->detail($param['id']);

        return $this->success('success', $data);
    }

}